package hdf5.parser;

import java.util.ArrayList;
import java.util.List;

public class Array2DCreator {

    private int xCells;
    private int yCells;

    public Array2DCreator(int xCells, int yCells){
        this.xCells = xCells;
        this.yCells = yCells;
    }

    public List<double[][]> get2DList(List<double[]> dateList) {
        List<double[][]> list = new ArrayList<double[][]>();
        for (double[] date : dateList) {
            list.add(createArray2d(date, xCells, yCells));
        }
        return list;
    }

    public double[][] createArray2d(double[] array1D, int rowCount, int columnCount) {
        double[][] array2D = new double[rowCount][columnCount];
        for (int i = 0; i < rowCount; i++) {
            System.arraycopy(array1D, i * rowCount, array2D[i], 0, columnCount);
        }
        return array2D;
    }

    public void setDimensions(int xCount, int yCount) {
        xCells = xCount;
        yCells = yCount;
    }
}
